<template>
  <div class="init_main">
    <p class="name_sty">{{ name }}</p>
    <div>
      <el-date-picker
        v-model="query.year"
        type="year"
        value-format="yyyy"
        format="yyyy 年"
        placeholder="选择年"
      >
      </el-date-picker>
      <el-date-picker
        v-model="query.month"
        type="month"
        value-format="MM"
        format="MM 月"
        placeholder="选择月"
      >
      </el-date-picker>
      <el-select v-model="query.section" placeholder="请选择" clearable>
        <el-option
          v-for="item in tableData"
          :key="item.Name"
          :label="item.Name"
          :value="item.Name"
        >
        </el-option>
      </el-select>
      <el-select v-model="query.name" placeholder="请选择" clearable>
        <el-option label="年龄" value="年龄"> </el-option>
        <el-option label="现学历" value="现学历"> </el-option>
        <el-option label="现聘护理职称" value="现聘护理职称"> </el-option>
        <el-option label="护士鞋号码" value="护士鞋号码"> </el-option>
      </el-select>
      <el-button icon="el-icon-search" @click="getList2"></el-button>
    </div>
    <div class="table">
      <el-table
        :data="tableData2"
        border
        style="width: 100%"
        height="800"
        highlight-current-row
        @current-change="row_click"
      >
        <el-table-column prop="Name" label="名称"> </el-table-column>
        <el-table-column prop="Count" label="人数"> </el-table-column>
        <el-table-column prop="Percent" label="占比">
          <template slot-scope="scope">
            <span>{{ scope.row.Percent }}%</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      name: "",
      tableData: [],
      tableData2: [],
      query: {
        year: "",
        month: "",
        section: "",
        name: "",
      },
    };
  },
  mounted() {
    this.name = this.$route.meta.title;
    this.getList();
  },
  methods: {
    getList() {
      console.log(this.query);
      this.$get("/BsTj/Section1").then((res) => {
        this.tableData = res.Data;
      });
    },
    getList2() {
      console.log(this.query);
      this.$post("/BsTj/PercentTj", this.query).then((res) => {
        if (res.StatusCode != 200) {
          this.$notify.error({
            title: "错误",
            message: res.Errors,
          });
          return;
        }
        this.tableData2 = res.Data;
      });
    },
    row_click(row) {
      this.section = row.Name;
    },
    goto_da(val) {
      console.log(val);
      this.$router.push(
        "/RYDA/daxx?人员ID=" +
          val._id +
          "&人员姓名=" +
          val.Data.姓名 +
          "&按钮权限=true"
      );
    },
  },
};
</script>

<style scoped lang='scss'>
.init_main {
  background-color: #fff;
  height: calc(100vh - 60px);
  border: 1px solid #333;
  border-radius: 5px;
  margin: 5px;
  padding: 10px;
  font-family: "FangSong";
  color: #000;
  .name_sty {
    color: #000;
    font-weight: 700;
    font-size: 18px;
    font-family: "FangSong";
    border-bottom: 1px solid #333;
    padding-bottom: 5px;
  }
  .table {
    margin-top: 15px;
  }
  .page {
    text-align: right;
  }
}
::v-deep .el-table__body tr.current-row > td.el-table__cell {
  background-color: rgb(208, 229, 250);
  color: rgb(65, 158, 255);
  font-weight: 700;
}
.tac {
  text-align: center;
}
</style>